package com.myk.game.gobangchess.ai.gravityfour;

import java.util.Arrays;

public class StartingSets {

    public static int[] startingSets(int[][] board, int direction, int player_turn, int dir_changed) {
        int succ = 0;
        int pointsets1 = 0;
        int pointsets2 = 0;

        int[][][] boardList = {
                {{0, 0, 1, 0, 0, 0},
                 {0, 0, 0, 0, 0, 0},
                 {0, 0, 0, 0, 0, 0},
                 {0, 0, 0, 0, 0, 0},
                 {0, 0, 0, 0, 0, 0},
                 {0, 0, 0, 0, 0, 0}},
                
                {{0, 0, 0, 1, 0, 0},
                 {0, 0, 0, 0, 0, 0},
                 {0, 0, 0, 0, 0, 0},
                 {0, 0, 0, 0, 0, 0},
                 {0, 0, 0, 0, 0, 0},
                 {0, 0, 0, 0, 0, 0}},
                
                {{0, 0, 0, 0, 0, 0},
                 {0, 0, 0, 0, 0, 0},
                 {0, 0, 0, 0, 0, 0},
                 {0, 0, 0, 0, 0, 0},
                 {0, 0, 0, 0, 0, 0},
                 {0, 0, 0, 0, 0, 0}},
                
                {{0, 1, 0, 0, 0, 0},
                 {0, 0, 0, 0, 0, 0},
                 {0, 0, 0, 0, 0, 0},
                 {0, 0, 0, 0, 0, 0},
                 {0, 0, 0, 0, 0, 0},
                 {0, 0, 0, 0, 0, 0}},
                
                {{0, 0, 0, 0, 1, 0},
                 {0, 0, 0, 0, 0, 0},
                 {0, 0, 0, 0, 0, 0},
                 {0, 0, 0, 0, 0, 0},
                 {0, 0, 0, 0, 0, 0},
                 {0, 0, 0, 0, 0, 0}},
                
                {{1, 0, 0, 0, 0, 0},
                 {0, 0, 0, 0, 0, 0},
                 {0, 0, 0, 0, 0, 0},
                 {0, 0, 0, 0, 0, 0},
                 {0, 0, 0, 0, 0, 0},
                 {0, 0, 0, 0, 0, 0}},
                
                {{0, 0, 0, 0, 0, 1},
                 {0, 0, 0, 0, 0, 0},
                 {0, 0, 0, 0, 0, 0},
                 {0, 0, 0, 0, 0, 0},
                 {0, 0, 0, 0, 0, 0},
                 {0, 0, 0, 0, 0, 0}},

                 {{0, 0, 0, 0, 0, 0},
                 {0, 0, 0, 0, 0, 0},
                 {0, 0, 0, 0, 0, 0},
                 {0, 0, 0, 0, 0, 0},
                 {0, 0, 0, 0, 0, 0},
                 {0, 0, 0, 0, 0, 0}},

                 {{0, 0, 0, 0, 0, 0},
                 {0, 0, 0, 0, 0, 0},
                 {0, 0, 0, 0, 0, 0},
                 {0, 0, 0, 0, 0, 0},
                 {0, 0, 0, 0, 0, 0},
                 {0, 0, 0, 0, 0, 0}},

                 {{0, 0, 0, 0, 0, 0},
                 {0, 0, 0, 0, 0, 0},
                 {0, 0, 0, 0, 0, 0},
                 {0, 0, 0, 0, 0, 0},
                 {0, 0, 0, 0, 0, 0},
                 {0, 0, 0, 0, 0, 0}},

                 {{0, 0, 0, 0, 1, -1},
                 {0, 0, 0, 0, 0, 0},
                 {0, 0, 0, 0, 0, 0},
                 {0, 0, 0, 0, 0, 0},
                 {0, 0, 0, 0, 0, 0},
                 {0, 0, 0, 0, 0, 0}},

                 {{0, 0, 0, 0, -1, 1},
                 {0, 0, 0, 0, 0, 0},
                 {0, 0, 0, 0, 0, 0},
                 {0, 0, 0, 0, 0, 0},
                 {0, 0, 0, 0, 0, 0},
                 {0, 0, 0, 0, 0, 0}},

                 {{-1, 1, 0, 0, 0, 0},
                 {0, 0, 0, 0, 0, 0},
                 {0, 0, 0, 0, 0, 0},
                 {0, 0, 0, 0, 0, 0},
                 {0, 0, 0, 0, 0, 0},
                 {0, 0, 0, 0, 0, 0}},

                 {{1, -1, 0, 0, 0, 0},
                 {0, 0, 0, 0, 0, 0},
                 {0, 0, 0, 0, 0, 0},
                 {0, 0, 0, 0, 0, 0},
                 {0, 0, 0, 0, 0, 0},
                 {0, 0, 0, 0, 0, 0}},

                 {
                    {0, 0, -1, 1, 1, 0},
                    {0, 0, 1, 0, 0, 0},
                    {0, 0, -1, 0, 0, 0},
                    {0, 0, 0, 0, 0, 0},
                    {0, 0, 0, 0, 0, 0},
                    {0, 0, 0, 0, 0, 0}
                },
                {
                    {0, 1, 1, -1, 0, 0},
                    {0, 0, 0, 1, 0, 0},
                    {0, 0, 0, -1, 0, 0},
                    {0, 0, 0, 0, 0, 0},
                    {0, 0, 0, 0, 0, 0},
                    {0, 0, 0, 0, 0, 0}
                },
                {
                    {0, 0, -1, 1, 0, 1},
                    {0, 0, 1, 0, 0, 0},
                    {0, 0, -1, 0, 0, 0},
                    {0, 0, 0, 0, 0, 0},
                    {0, 0, 0, 0, 0, 0},
                    {0, 0, 0, 0, 0, 0}
                },
                {
                    {1, 0, 1, -1, 0, 0},
                    {0, 0, 0, 1, 0, 0},
                    {0, 0, 0, -1, 0, 0},
                    {0, 0, 0, 0, 0, 0},
                    {0, 0, 0, 0, 0, 0},
                    {0, 0, 0, 0, 0, 0}
                }
        };

        int[] directionList = {9, 9, 9, 9, 9, 9, 9,7,8,10,10,10,8,8,9,9,9,9};
        int[] playerTurnList = {-1, -1, 1, -1, -1, -1, -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1};
        int[] dirChangedList = {0, 0, 0, 0, 0, 0, 0,1,1,1,1,1,1,1,0,0,0,0};
        int[] pointsets1List = {6, 6, 6, 6, 6, 6, 6,6,3,4,3,3,3,3,6,6,6,6};
        int[] pointsets2List = {4, 3, 4, 3, 4, 3, 4,3,6,6,1,1,6,6,4,3,4,3};

        for (int i = 0; i < dirChangedList.length; i++) {
            if (Arrays.deepEquals(board, boardList[i]) &&
                    direction == directionList[i] &&
                    player_turn == playerTurnList[i] &&
                    dir_changed == dirChangedList[i]) {
                succ = 1;
                pointsets1 = pointsets1List[i];
                pointsets2 = pointsets2List[i];
                break;
            }
        }

        int[] result = {succ, pointsets1, pointsets2};
        return result;
    }
}